home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0071_OP Pick Lists.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  6KB  |  176 lines

  1. {
  2. >I've been trying to create a simple pick list using Object Proffesional and
  3. >can't seem to get it to do what I want. I'm using the expick.pas example as
  4. >start for creating my pick list. Everything is pretty much the same except
  5. >that I want my pick list to exit with other keys insted of the enter key.
  6. >The manual doesn't go into detail about this.
  7.  
  8. Check out the docs for OpCmd.  The procedure that you're wanting is
  9. "AddCommand".   In my example below, I've set up a multiple choice list
  10. that "remaps" the <Enter> key to toggle (like the <SpaceBar>) and use
  11. <F10> to accept the choices.  Here's my example:
  12.  
  13. {DON'T FORGET TO "USE" OpCmd}
  14.  
  15. uses
  16.    OpCmd; {among others}
  17.  
  18. procedure GetPicks;
  19. var
  20.    PL                  :PickList;
  21.    PickDone            :boolean;
  22.  
  23. begin
  24.    if not PL.InitDeluxe(screenwidth shr 1-16,5,
  25.                         screenwidth shr 1+15,screenheight-6,
  26.                         AltMenuCS,     {color set}
  27.                         WinOpts,       {window options}
  28.                         33,            {width of pick list strings}
  29.                         NumItems,      {number of items}
  30.                         UserStrings,   {user-string proc}
  31.                         PickVertical,  {pick direction-type}
  32.                         MultipleChoice,{single or multiple}
  33.                         pkStick)then   {stick at edges}
  34.     begin
  35.         {error message}
  36.         exit;
  37.     end;
  38.     PickCommands.AddCommand(ccToggle,1,$1C0D,0); {Enter=Toggle}
  39.     PickCommands.AddCommand(ccSelect,1,$4400,0); {F10=Accept}
  40.     PickDone:=false;
  41.     repeat
  42.        PL.Process;
  43.        case PL.GetLastCommand of
  44.           ccSelect:  {F10}
  45.              begin
  46.              end;
  47.  
  48.            ccQuit:
  49.               PickDone:=true;
  50.  
  51.            ccError:
  52.               begin
  53.                  PickDone:=true;
  54.               end;
  55.         end; {case}
  56.      until PickDone;
  57.      HideMouse;
  58.  
  59.      {NOTE THE FOLLOWING LINES:  They're needed to remap the <Enter>
  60.       key to its original setting and gets rid of the <F10> key as
  61.       the ccSelect.  If you want *ALL* of your pick lists throughout
  62.       your program to behave this way, use the PickCommands.AddCommand
  63.       at the beginning of your program.}
  64.  
  65.       PickCommands.AddCommand(ccSelect,1,$1C0D,0); {Enter=Toggle}
  66.       PickCommands.AddCommand(ccNone,1,$4400,0); {F10=Accept}
  67.       PL.Done;
  68.    end;
  69. end;
  70.  
  71. {
  72. CHARLES SERFOSS
  73.  
  74. >I've been trying to create a simple pick list using Object Proffesional and
  75. >can't seem to get it to do what I want. I'm using the expick.pas example as a
  76. >start for creating my pick list. Everything is pretty much the same except
  77. >that I want my pick list to exit with other keys insted of the enter key.
  78. >The manual doesn't go into detail about this.
  79.  
  80. You'll have to use the "AddCommand" method.  Here's an example.  This is
  81. based on "expick1.pas" from Page 4-186 of Book #1.
  82. }
  83.  
  84. program PickListExample;
  85. uses
  86.         OpCrt, OpRoot, OpCCmd, OpFrame, OpWindow, OpPick;
  87. const
  88.         NumPizzaToppings = 5;
  89. var
  90.         PizzaTop : PickList;
  91.         PickWindowOptions : Longint;
  92.  
  93. procedure PizzaTopping(Item : Word { etc... }) : Far;
  94. begin
  95. end;
  96.  
  97. begin { Main }
  98.         if not PizzaTop.InitCustom(35, 5, 45, { etc ... }) then begin
  99.                 halt;
  100.         end;
  101.         PizzaTop.SetSearchMode(PicckCharSearch);
  102.         PizzaTop.EnableExplosion(20);
  103.         with PizzaTop.wFrame do begin
  104.                 AddShadow...
  105.                 AddHeader...
  106.         end;
  107.         { *************** Decide Which Keys In Addition To Defaults To Allow }
  108.         { PickCommands is just mentioned at the end of page 4-207.  The      }
  109.         { CommandProcessor Type allows you to use the functions in section   }
  110.         { (E) OPCMD - Page 3-82.  See Page 3-95 for documentation on         }
  111.         { the "AddCommand" method!                                           }
  112.         { *******************************************************************}
  113.         with PickCommands do
  114.         begin
  115.                 AddCommand(ccUser1,1,$5200,0); { $5200 = scan code for INS }
  116.                 AddCommand(ccUser2,1,$5300,0); { $5300 = scan code for DEL }
  117.         end;
  118.         PizzaTop.Process;
  119.         PizzaTop.Erase;
  120.         case PizzaTop.GetLastCommand of
  121.                 ccUser1 : ; { If User hits INS, this is executed }
  122.                 ccUser2 : ; { If User hits DEL, this is executed }
  123.                 ccSelect : writeln('You chose : ',PizzaTop.GetLastChoiceString);
  124.         end;
  125.         PizzaTop.Done;
  126. end. { Main }
  127.  
  128. {
  129. DAVID HOWORTH
  130.  
  131. > I've been trying to create a simple pick list using Object Proffesional
  132. > can't seem to get it to do what I want. I'm using the expick.pas exampl
  133. > start for creating my pick list. Everything is pretty much the same exc
  134. > that I want my pick list to exit with other keys insted of the enter ke
  135. > The manual doesn't go into detail about this.
  136.  
  137. Nick--The manual does go into subtantial detail.  You just need to
  138. know where to look.  As with much of OPro, the things you want to
  139. do with a particular object may be implemented, not in the object
  140. per se, but in one of its ancestors.  It always pays to look in the
  141. manual at the ancestor's methods.
  142.  
  143. You need to read up on CommandWindow, from which PickList is
  144. descended, and on CommandProcessor, in OpCmd.  Here's a relevant
  145. piece of code from one of my programs.  The first AddCommand adds
  146. an additional Quit; the others are for purposes specific to my
  147. application, not for predefined commands such as ccQuit.
  148. }
  149. with DialPickList { a PickList descendent } do
  150.  
  151.    with PickCommands do begin
  152.      { Simulate WordPerfect's exit command }
  153.      AddCommand(ccQuit,1,$4100,0);       { F7 }
  154.  
  155.      { ccUser0 = Add a new phone entry }
  156.      AddCommand(ccUser0,1,$1E00,0);      {Alt-A}
  157.      AddCommand(ccUser0,1,$5200,0);      {Ins}
  158.  
  159.      { ccUser1 = Delete a phone entry }
  160.      AddCommand(ccUser1,1,$2000,0);      {Alt-D}
  161.      AddCommand(ccUser1,1,$5300,0);      {Del}
  162.  
  163.      { ccUser2 = Edit a phone entry }
  164.      AddCommand(ccUser2,1,$1200,0);      {Alt-E}
  165.  
  166.      { ccUser3 = Reconfigure Comm Stuff }
  167.      AddCommand(ccUser3,1,$2E00,0);      {Alt-C}
  168.  
  169.      { ccUser4 = View log (the printing and purging routines branch
  170.        from the browsing routine }
  171.      AddCommand(ccUser4,1,$2F00,0);      {Alt-V}
  172.  
  173.   end; { with PickCommands }
  174.  
  175. end; { with DialPickList }
  176.